package com.hubing.cloud.app.web.controller;

import com.alibaba.fastjson2.JSONObject;
import com.hubing.cloud.app.web.config.minio.MinioFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("common")
public class CommonController {

    @Autowired
    private MinioFileService minioFileService;

    /**
     * 通用上传请求
     */
    @PostMapping("/upload")
    public JSONObject uploadFile(MultipartFile file) {
        try{
            // 上传文件路径
            return minioFileService.upload(file);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
